<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateEnroll extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = <<<SQL
        create table taoke_enroll
        (
          id int(10) unsigned not null auto_increment
            primary key,
          uid int unsigned not null,
          fee int unsigned DEFAULT 0,
          area varchar(200) not null comment '片区',
          campus varchar(200) not null comment '校区',
          address varchar(200) null comment '详细地址',
          grade VARCHAR(200) not null comment '年纪',
          semester varchar(200) not null comment '学期',
          subject text not null comment '学科',
          student_name varchar(200) not null comment '学生姓名',
          contact VARCHAR(20) not null comment '联系方式',
          out_trade_no VARCHAR(200) NULL ,
          pay_status int DEFAULT 0 comment '支付状态;0,未支付;1,已支付',
          pay_time timestamp null default null,
          created_at timestamp null DEFAULT null,
          updated_at timestamp not null default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
          deleted_at timestamp null default null
        ) DEFAULT CHARSET=utf8mb4;
SQL;
        if (!DB::statement($sql)) {
            throw new \Exception("failed on execute SQL: [{$sql}]");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        throw new \Exception('downgrade is forbidden');
    }
}
